package org.example.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.stereotype.Component;

/**
 * SpringBean工具包
 *
 * @author bobo
 * @since 2024/4/26
 */
@Component
public class SpringUtil {

	private static final ApplicationContext applicationContext;

	static {
		applicationContext = new AnnotationConfigApplicationContext(SpringConfig.class);
	}

	public static  <T> T getBean(Class<T> requiredType) {
		return SpringUtil.applicationContext.getBean(requiredType);
	}
}
